home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / newmat03.lha / newmat03 / newmat9.cxx < prev    next >
C/C++ Source or Header  |  1993-08-08  |  946b  |  41 lines

  1. //$$ newmat9.cxx         Input and output
  2.  
  3. // Copyright (C) 1991: R B Davies and DSIR
  4.  
  5.  
  6. #define WANT_STREAM
  7.  
  8. #include "include.hxx"
  9.  
  10. #include "newmat.hxx"
  11. #include "newmatrc.hxx"
  12. #include "newmatio.hxx"
  13.  
  14. //#define REPORT { static ExeCounter ExeCount(__LINE__,9); ExeCount++; }
  15.  
  16. #define REPORT {}
  17.  
  18. ostream& operator<<(ostream& s, BaseMatrix& X)
  19. {
  20.    GeneralMatrix* gm = X.Evaluate(); operator<<(s, *gm);
  21.    gm->tDelete(); return s;
  22. }
  23.  
  24.  
  25. ostream& operator<<(ostream& s, const GeneralMatrix& X)
  26. {
  27.    int w = s.width();  int nr = X.Nrows();  long f = s.flags();
  28.    s.setf(ios::fixed, ios::floatfield);
  29.    MatrixRow mr((GeneralMatrix*)&X, LoadOnEntry);
  30.    for (int i=1; i<=nr; i++)
  31.    {
  32.       int skip = mr.skip;  int storage = mr.storage;
  33.       real* store = mr.store+skip;  skip *= w+1;
  34.       while (skip--) s << " ";
  35.       while (storage--) s << setw(w) << *store++ << " ";
  36.       mr.Next();  s << "\n";
  37.    }
  38.    s << flush;  s.flags(f); return s;
  39. }
  40.  
  41.